package com.shensi.common.core.exception;

import com.shensi.common.core.utils.IResultCode;

/**
 * 自定义异常
 *
 * @author qujia
 */
public class CustomException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private Integer code;

    private String message;

    public CustomException(String message) {
        this.message = message;
    }

    public CustomException(String message, Integer code) {
        this.message = message;
        this.code = code;
    }

    public CustomException(IResultCode code) {
        this(code.getMsg(), code.getCode());
    }

    public CustomException(String message, Throwable e) {
        super(message, e);
        this.message = message;
    }

    @Override
    public String getMessage() {
        return this.toString();
    }

    public String getMsg() {
        return this.message;
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String toString() {
        return "CustomException{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
